{#include file="admin_header.htm"#}
<div class="admin_main_nr_dbox">
  <form action="?act=site_admin_navigation_save" method="post"  name="form1" id="form1">
    <table width="700" border="0" cellspacing="0" cellpadding="5" style="border-bottom:1px #CCCCCC solid;">
      <tr>
        <td width="533" height="25" style="font-size:14px;">已選快捷按鈕</td>
        <td width="69" style="font-size:14px;"><input type="submit" name="Submit2" value="保存修改" class="Qishi_submit_a" onmouseover="this.className='Qishi_submit_b'"  onmouseout="this.className='Qishi_submit_a'"/></td>
      </tr>
    </table>
    <div  style=" width:310px;float:left; padding:10px;">
	<div id="previewItem" style="line-height:25px;">
	</div>
    </div>
	</form>
	<div style="width:330px; float:left; border-left:1px #CCCCCC solid; padding:10px;">
	<div id="selectSub">
	{#section name=category_all loop=$category_list#}
	<div style="width:330px; padding:5px; font-size:14px; border:1px #CCCCCC solid; background-color:#EBEFFA; margin-top:5px; margin-bottom:5px;">{#$category_list[category_all].categoryname#}</div>
	{#section name=category_f loop=$category_list[category_all].category#}	
	<div style="width:110px; height:28px; line-height:28px; float:left;"><input name="myinput" type="checkbox" onclick="addPreItem()" value="{#$category_list[category_all].category[category_f].id#}" {#if $category_list[category_all].category[category_f].is_show==1#}checked="checked"{#/if#}/><input name="items_name" type="hidden" value="{#$category_list[category_all].category[category_f].categoryname#}" /><input name="px" type="hidden" value="{#$category_list[category_all].category[category_f].category_order#}" />{#$category_list[category_all].category[category_f].categoryname#}
	</div>
	{#/section#}
	<div class="clear"></div>
	{#/section#}
   </div>
</div>
<div class="clear"></div>
<div  style=" width:700px; border-bottom:1px #CCCCCC solid; height:1px;"></div>
</div>
<script type="text/javascript">
function $(o){ //獲取對象
 if(typeof(o) == "string")
 return document.getElementById(o);
 return o;
}
//showSelect(showGrow);getElementsByTagName()getElementsByName()
var items = document.getElementsByName("myinput");
var items_name = document.getElementsByName("items_name");
var px = document.getElementsByName("px");
//alert(items_name.length);//所有多選的數量
var lenMax = 6; 
//alert(1);//最多選擇幾項
addPreItem();
//添加多選項目
function addPreItem(){ 
 $("previewItem").innerHTML = "";
 var len　= 0 ;
 for(var i = 0 ; i < items.length ; i++)
 {
  if(items[i].checked == true)//判斷數否超出最大選擇數量
  {
   len++;
   if(len > lenMax)
   {
    alert("不能超過" + lenMax +"個選項！")
    return false;
   }
   var mes = "<div style=\"float:left; width:130px;\">";
   mes += "<input name='is_show[]' type='checkbox' checked='true' value='"+ items[i].value +"' onclick='copyItem(\"previewItem\",\"previewItem\");same(this);'>" + items_name[i].value+"";
   mes +="</div>";
   mes += "<div style=\"float:left;\">";
   mes += "排序：<input name=\"category_order[]\" type=\"text\" value=\""+ px[i].value +"\" onkeyup='ck_number(this)' style=\" width:35px;\" maxlength=\"3\"\/>";
   mes += "<input name=\"c_name[]\" type=\"hidden\" value=\""+ items_name[i].value +"\" \/>";
   mes +="</div>";
   mes +="<div class=\"clear\"></div>";
   $("previewItem").innerHTML += mes;
   //alert(items[i].value);
  }
 }
}
function copyItem(id1,id2){ 
 var mes = "";
var left_items = document.getElementsByName("is_show[]");
var left_name = document.getElementsByName("c_name[]");
var left_px = document.getElementsByName("category_order[]");
 for(var i = 0 ; i < left_items.length ; i++)
 {
  if(left_items[i].checked == true)
  {
   mes += "<div style=\"float:left; width:130px;\">";
   mes += "<input name='is_show[]' type='checkbox' checked='true' value='"+ left_items[i].value +"' onclick='copyItem(\"previewItem\",\"previewItem\");same(this);'>" + left_name[i].value+"";
   mes +="</div>";
   mes += "<div style=\"float:left;\">";
   mes += "排序：<input name=\"category_order[]\" type=\"text\" value=\""+ left_px[i].value +"\" onkeyup='ck_number(this)' style=\" width:35px;\" maxlength=\"3\"\/>";
   mes += "<input name=\"c_name[]\" type=\"hidden\" value=\""+ left_name[i].value +"\" \/>";
   mes +="</div>";
   mes +="<div class=\"clear\"></div>";
  }
 }
 $(id2).innerHTML = "";
 $(id2).innerHTML += mes;
 //alert($(id2).innerHTML);
}
function same(ck){
 for(var i = 0 ; i < items.length ; i++)
 {
  if(ck.value == items[i].value)
  {
   items[i].checked = ck.checked;
  }
 }
}
function ck_number(dd){
if(event.keyCode !=37 && event.keyCode != 39)
{
dd.value=dd.value.replace(/\D/g,'');
}
} 
//document.onmouseup = function(){oDrag = "";}
//document.onmousemove = function(event){dragPro(event);}
</script>
{#include file="admin_footer.htm"#}
</body>
</html>
